(function (aopc) {
    aopc.addExpandPage(816, function (get) {
        const Bridge = get('UtilsCommon', 'Bridge');

        return {
            expandInit() {
                this.userSignList = this.getProperty('UserSignList');
            },
            allSignToMainPage({ property }) {
                if (property.isLoading) return;
                const { serviceName, actionName } = property.serviceInterface;
                const { MeetingId } = this.pageData;
                const payload = { Meeting: { IsInSign: 0, IsAllSign: 1 }, pathQuery: `(${MeetingId})` };

                this.confirm('确定要全签到并至主页吗？', () => {
                    property.isLoading = true;
                    this.dispatchAction(serviceName, actionName, payload).then(res => {
                        if (res.isSuccess !== false) {
                            const url = '/meetingSubjectList.html?MeetingId=' + MeetingId;
                            this.webSocket.send('replacePage', { url });
                            this.replacePage(url);
                        }
                        property.isLoading = false;
                    });
                });
            },
            allCancelToWelcomePage({ property }) {
                if (property.isLoading) return;
                const { serviceName, actionName } = property.serviceInterface;
                const { MeetingId } = this.pageData;

                const payload = { pathQuery: `(${MeetingId})` };

                this.confirm('确定要全取签并至欢迎页吗？', () => {
                    property.isLoading = true;
                    this.dispatchAction(serviceName, actionName, payload).then(res => {
                        if (res.isSuccess !== false) {
                            const url = '/welcome.html?MeetingId=' + MeetingId;
                            this.webSocket.send('replacePage', { url });
                            this.replacePage(url);
                        }
                        property.isLoading = false;
                    });
                });
            },
            toUserSign({ property }) {
                if (property.isLoading) return;
                const { serviceName, actionName } = property.serviceInterface;
                const { MeetingId } = this.pageData;
                const payload = { Meeting: { IsEndSign: 0 }, pathQuery: `(${MeetingId})` };

                this.confirm('确定发起会签吗？', () => {
                    property.isLoading = true;
                    this.dispatchAction(serviceName, actionName, payload).then(res => {
                        if (res.isSuccess !== false) {
                            const url = '/userSign.html?MeetingId=' + MeetingId;
                            this.toPage(url);
                            this.webSocket.send('toPage', { url });
                        }
                        property.isLoading = false;
                    });
                });
            },
            endSign({ property }) {
                if (property.isLoading) return;
                const { serviceName, actionName } = property.serviceInterface;
                const { MeetingId } = this.pageData;
                const payload = { Meeting: { IsEndSign: 1 }, pathQuery: `(${MeetingId})` };

                this.confirm('确定结束会签吗？', () => {
                    property.isLoading = true;
                    this.dispatchAction(serviceName, actionName, payload).then(res => {
                        if (res.isSuccess !== false) {
                            this.alert('结束会签操作成功！');
                        }
                        property.isLoading = false;
                    });
                });
            },
            countToBigScreen() {
                const { MeetingId } = this.pageData;
                const { MeetingRoomId } = this.visitUser;
                this.webSocket.send('countToBigScreen', { MeetingId, MeetingRoomId, userId: this.visitUser.UserId });
                this.alertSuccess('签到统计至大屏消息已发出！');
            },
            closeCountBigScreen() {
                this.webSocket.send('closeCountBigScreen');
                this.alertSuccess('关闭大屏签到统计消息已发出！');
            },
            exportUserSigns() {
                Bridge.exportUserSigns(this.userSignList.dataSource);
            }
        }
    });
})(window.aopc);